﻿
// FONTView.cpp: CFONTView 类的实现

#include "pch.h"
#include "framework.h"
// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的
// ATL 项目中进行定义，并允许与该项目共享文档代码。
#ifndef SHARED_HANDLERS
#include "FONT.h"
#endif

#include "FONTDoc.h"
#include "FONTView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CFONTView

IMPLEMENT_DYNCREATE(CFONTView, CView)

BEGIN_MESSAGE_MAP(CFONTView, CView)
	// 标准打印命令
	ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CFONTView::OnFilePrintPreview)
	ON_WM_CONTEXTMENU()
	ON_WM_RBUTTONUP()
END_MESSAGE_MAP()

// CFONTView 构造/析构

CFONTView::CFONTView()noexcept
//移除异常规范,异常规范被标记为废弃,被 noexcept关键字替代
{
	// TODO: 在此处添加构造代码

}

CFONTView::~CFONTView()
{
}

BOOL CFONTView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: 在此处通过修改
	//  CREATESTRUCT cs 来修改窗口类或样式

	return CView::PreCreateWindow(cs);
}

// CFONTView 绘制

void CFONTView::OnDraw(CDC* pDC)
{
	CFONTDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	// TODO: 在此处为本机数据添加绘制代码
	//字体对象CFONT对象
	CFont* pOldFont1;
	CFont* pNewFont1 = new CFont;
	////设置新字体的各种属性
	pNewFont1->CreateFont(30,//字体高度30
		30,//字体宽度30
		1800,//文本字符倾斜角度180
		0,//每个字符与x轴角度
		0, //字体粗细
		FALSE, //是否为斜体
		FALSE, //是否带下划线
		0,//是否带删除线
		ANSI_CHARSET,//使用ANSI字符集
		OUT_DEFAULT_PRECIS,//输出精度——这里是默认精度
		CLIP_DEFAULT_PRECIS, //剪裁精度——这里是默认剪裁
		DEFAULT_QUALITY,//输出质量——这里是默认质量
		DEFAULT_PITCH & FF_SWISS,//字体间距和家族
		_T("字体1"));//字体名称
	pOldFont1 = (CFont*)pDC->SelectObject(pNewFont1);//SelectObject--将一个图形对象(笔）pOIdFont1选入设备上下文（屏幕）
	pDC->TextOut(450, 800, _T("00P程序设计！"));//显示文本
	pDC->SelectObject(pOldFont1);//之前保存的旧字体重新选入设备上下文
	delete pNewFont1;

	CFont* pOldFont2;
	CFont* pNewFont2 = new CFont;
	pNewFont2->CreateFont(30, 30, 1500, 0,
		0, FALSE, FALSE, 0,
		ANSI_CHARSET, OUT_DEFAULT_PRECIS,
		CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
		DEFAULT_PITCH & FF_SWISS,
		_T("字体2"));
	pOldFont2 = (CFont*)pDC->SelectObject(pNewFont2);
	pDC->TextOut(600, 700, _T("00P程序设计！"));
	pDC->SelectObject(pOldFont2);
	delete pNewFont2;

	CFont* pOldFont3;
	CFont* pNewFont3 = new CFont;
	pNewFont3->CreateFont(30, 30, 1200, 0,
		0, FALSE, FALSE, 0,
		ANSI_CHARSET, OUT_DEFAULT_PRECIS,
		CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
		DEFAULT_PITCH & FF_SWISS,
		_T("字体3"));
	pOldFont3 = (CFont*)pDC->SelectObject(pNewFont3);
	pDC->TextOut(750, 600, _T("00P程序设计！"));
	pDC->SelectObject(pOldFont3);
	delete pNewFont3;

	CFont* pOldFont4;
	CFont* pNewFont4 = new CFont;
	pNewFont4->CreateFont(30, 30, 900, 0,
		0, FALSE, FALSE, 0,
		ANSI_CHARSET, OUT_DEFAULT_PRECIS,
		CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
		DEFAULT_PITCH & FF_SWISS,
		_T("字体4"));
	pOldFont4 = (CFont*)pDC->SelectObject(pNewFont4);
	pDC->TextOut(900, 500, _T("00P程序设计！"));
	pDC->SelectObject(pOldFont4);
	delete pNewFont4;

	CFont* pOldFont5;
	CFont* pNewFont5 = new CFont;
	pNewFont5->CreateFont(30, 30, 600, 0,
		0, FALSE, FALSE, 0,
		ANSI_CHARSET, OUT_DEFAULT_PRECIS,
		CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
		DEFAULT_PITCH & FF_SWISS,
		_T("字体5"));
	pOldFont5 = (CFont*)pDC->SelectObject(pNewFont5);
	pDC->TextOut(1050, 600, _T("00P程序设计！"));
	pDC->SelectObject(pOldFont5);
	delete pNewFont5;

	CFont* pOldFont6;
	CFont* pNewFont6 = new CFont;
	pNewFont6->CreateFont(30, 30, 300, 0,
		0, FALSE, FALSE, 0,
		ANSI_CHARSET, OUT_DEFAULT_PRECIS,
		CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
		DEFAULT_PITCH & FF_SWISS,
		_T("字体6"));
	pOldFont6 = (CFont*)pDC->SelectObject(pNewFont6);
	pDC->TextOut(1200, 700, _T("00P程序设计！"));
	pDC->SelectObject(pOldFont6);
	delete pNewFont6;

	CFont* pOldFont7;
	CFont* pNewFont7 = new CFont;
	pNewFont7->CreateFont(30, 30, 0, 0,
		0, FALSE, FALSE, 0,
		ANSI_CHARSET, OUT_DEFAULT_PRECIS,
		CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
		DEFAULT_PITCH & FF_SWISS,
		_T("字体7"));
	pOldFont7 = (CFont*)pDC->SelectObject(pNewFont7);
	pDC->TextOut(1350, 800, _T("00P程序设计！"));
	pDC->SelectObject(pOldFont7);
	delete pNewFont7;

	CFont* pOldFont8;
	CFont* pNewFont8 = new CFont;
	pNewFont8->CreateFont(25, 25, 0, 0,
		0, FALSE, FALSE, 0,
		ANSI_CHARSET, OUT_DEFAULT_PRECIS,
		CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
		DEFAULT_PITCH & FF_SWISS,
		_T("字体8"));
	pOldFont8 = (CFont*)pDC->SelectObject(pNewFont8);
	pDC->TextOut(750, 650, _T("00P程序设计！"));
	pDC->SelectObject(pOldFont8);
	delete pNewFont8;

	CFont* pOldFont9;
	CFont* pNewFont9 = new CFont;
	pNewFont9->CreateFont(30, 30, 0, 0,
		0, FALSE, FALSE, 0,
		ANSI_CHARSET, OUT_DEFAULT_PRECIS,
		CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
		DEFAULT_PITCH & FF_SWISS,
		_T("字体9"));
	pOldFont9 = (CFont*)pDC->SelectObject(pNewFont9);
	pDC->TextOut(725, 700, _T("00P程序设计！"));
	pDC->SelectObject(pOldFont9);
	delete pNewFont9;

	CFont* pOldFont10;
	CFont* pNewFont10 = new CFont;
	pNewFont10->CreateFont(40, 40, 0, 0,
		0, FALSE, FALSE, 0,
		ANSI_CHARSET, OUT_DEFAULT_PRECIS,
		CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
		DEFAULT_PITCH & FF_SWISS,
		_T("字体10"));
	pOldFont10 = (CFont*)pDC->SelectObject(pNewFont10);
	pDC->TextOut(700, 750, _T("00P程序设计！"));
	pDC->SelectObject(pOldFont10);
	delete pNewFont10;

	CFont* pOldFont11;
	CFont* pNewFont11 = new CFont;
	pNewFont11->CreateFont(50, 50, 0, 0,
		0, FALSE, FALSE, 0,
		ANSI_CHARSET, OUT_DEFAULT_PRECIS,
		CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
		DEFAULT_PITCH & FF_SWISS,
		_T("字体11"));
	pOldFont11 = (CFont*)pDC->SelectObject(pNewFont11);
	pDC->TextOut(675, 800, _T("00P程序设计！"));
	pDC->SelectObject(pOldFont11);
	delete pNewFont11;

}


// CFONTView 打印


void CFONTView::OnFilePrintPreview()
{
#ifndef SHARED_HANDLERS
	AFXPrintPreview(this);
#endif
}

BOOL CFONTView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// 默认准备
	return DoPreparePrinting(pInfo);
}

void CFONTView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: 添加额外的打印前进行的初始化过程
}

void CFONTView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: 添加打印后进行的清理过程
}

void CFONTView::OnRButtonUp(UINT /* nFlags */, CPoint point)
{
	ClientToScreen(&point);
	OnContextMenu(this, point);
}

void CFONTView::OnContextMenu(CWnd* /* pWnd */, CPoint point)
{
#ifndef SHARED_HANDLERS
	theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE);
#endif
}


// CFONTView 诊断

#ifdef _DEBUG
void CFONTView::AssertValid() const
{
	CView::AssertValid();
}

void CFONTView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CFONTDoc* CFONTView::GetDocument() const // 非调试版本是内联的
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFONTDoc)));
	return (CFONTDoc*)m_pDocument;
}
#endif //_DEBUG


// CFONTView 消息处理程序